package cn.wjc.demo.part.three.controller;

import cn.wjc.demo.common.entity.Student;
import cn.wjc.demo.common.entity.Teacher;
import cn.wjc.demo.part.three.client.RemoteAddStudentFeignService;
import cn.wjc.demo.part.three.client.RemoteAddTeacherFeignService;
import cn.wjc.demo.part.three.service.IAddService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@RequestMapping("/partthree")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AddController {

    private final IAddService addService;

    @GetMapping("/test")
    public String test() {
        return "测试成功";
    }

    @GetMapping("/add")
    public String remoteAddStudentAndTeacher() {

        addService.remoteAddStudentAndTeacher();
        return "远程调用完毕，学生和老师添加完成";
    }

}
